'\" te
.\"  Copyright (c) 2002 by Sun Microsystems, Inc.  All rights reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH RSM_MEMSEG_IMPORT_MAP 3RSM "Nov 26, 2017"
.SH NAME
rsm_memseg_import_map, rsm_memseg_import_unmap \- map or unmap imported segment
.SH SYNOPSIS
.LP
.nf
cc [ \fIflag\fR... ] \fIfile\fR... -lrsm [ \fIlibrary\fR... ]
#include <rsmapi.h>

\fBint\fR \fBrsm_memseg_import_map\fR(\fBrsm_memseg_import_handle_t\fR \fIim_memseg\fR,
     \fBvoid **\fR\fIaddress\fR, \fBrsm_attribute_t\fR \fIattr\fR,
     \fBrsm_permission_t\fR \fIperm\fR, \fBoff_t\fR \fIoffset\fR, \fBsize_t\fR \fIlength\fR);
.fi

.LP
.nf
\fBint\fR \fBrsm_memseg_import_unmap\fR(\fBrsm_memseg_import_handle_t\fR \fIim_memseg\fR);
.fi

.SH DESCRIPTION
.LP
The \fBrsm_memseg_import_map()\fR and \fBrsm_memseg_import_unmap()\fR functions
provide for mapping and unmapping operations on imported segments. The mapping
operations are only available for native architecture interconnects such as
Dolphin-SCI or Sun Fire Link. Mapping a segment allows that segment to be
accessed by CPU memory operations, saving the overhead of calling the memory
access primitives described on the \fBrsm_memseg_import_get\fR(3RSM) and
\fBrsm_memseg_import_put\fR(3RSM) manual pages.
.sp
.LP
The \fBrsm_memseg_import_map()\fR function maps an import segment into caller's
address space for the segment to be accessed by CPU memory operations.  The
\fIim_memseg\fR argument represents the import segment that is being mapped.
The location where the process's address space is mapped to the segment is
pointed to by the  \fIaddress\fR argument. The \fIattr\fR argument can be one
of the following:
.sp
.ne 2
.na
\fB\fBRSM_MAP_NONE\fR \fR
.ad
.RS 18n
The system will choose available virtual address to map and return its value in
the \fIaddress\fR argument.
.RE

.sp
.ne 2
.na
\fB\fBRSM_MAP_FIXED\fR \fR
.ad
.RS 18n
The import segment should be mapped at the requested virtual address specified
in the  \fIaddress\fR argument.
.RE

.sp
.LP
The \fIperm\fR argument determines whether read, write or a combination of
accesses are permitted to the data being mapped. It can be either
\fBRSM_PERM_READ\fR, \fBRSM_PERM_WRITE\fR, or \fBRSM_PERM_RDWR\fR.
.sp
.LP
The \fIoffset\fR argument is the byte offset location from the base of the
segment being mapped to \fIaddress\fR. The \fIlength\fR argument indicates the
number of bytes from offset to be mapped.
.sp
.LP
The \fBrsm_memseg_import_unmap()\fR function unmaps a previously mapped import
segment.
.SH RETURN VALUES
.LP
Upon successful completion, these functions return 0. Otherwise, an error value
is returned to indicate the error.
.SH ERRORS
.LP
The \fBrsm_memseg_import_map()\fR and \fBrsm_memseg_import_unmap()\fR functions
can return the following errors:
.sp
.ne 2
.na
\fB\fBRSMERR_BAD_SEG_HNDL\fR \fR
.ad
.RS 24n
Invalid segment handle.
.RE

.sp
.LP
The \fBrsm_memseg_import_map()\fR function can return the following errors:
.sp
.ne 2
.na
\fB\fBRSMERR_BAD_ADDR\fR \fR
.ad
.RS 30n
Invalid address.
.RE

.sp
.ne 2
.na
\fB\fBRSMERR_BAD_LENGTH\fR \fR
.ad
.RS 30n
Invalid length.
.RE

.sp
.ne 2
.na
\fB\fBRSMERR_BAD_MEM_ALIGNMENT\fR\fR
.ad
.RS 30n
The address is not aligned on a page boundary.
.RE

.sp
.ne 2
.na
\fB\fBRSMERR_BAD_OFFSET\fR \fR
.ad
.RS 30n
Invalid offset.
.RE

.sp
.ne 2
.na
\fB\fBRSMERR_BAD_PERMS\fR \fR
.ad
.RS 30n
Invalid permissions.
.RE

.sp
.ne 2
.na
\fB\fBRSMERR_CONN_ABORTED\fR \fR
.ad
.RS 30n
Connection aborted.
.RE

.sp
.ne 2
.na
\fB\fBRSMERR_MAP_FAILED\fR \fR
.ad
.RS 30n
Map failure.
.RE

.sp
.ne 2
.na
\fB\fBRSMERR_SEG_ALREADY_MAPPED\fR \fR
.ad
.RS 30n
Segment already mapped.
.RE

.sp
.ne 2
.na
\fB\fBRSMERR_SEG_NOT_CONNECTED\fR \fR
.ad
.RS 30n
Segment not connected.
.RE

.SH ATTRIBUTES
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Evolving
_
MT-Level	MT-Safe
.TE

.SH SEE ALSO
.LP
.BR rsm_memseg_get_pollfd (3RSM),
.BR rsm_memseg_import_connect (3RSM),
.BR rsm_memseg_import_get (3RSM),
.BR rsm_memseg_import_put (3RSM),
.BR attributes (7)
